package liuwanghui.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import liuwanghui.common.Result;
import liuwanghui.dto.LoginDTO;
import liuwanghui.dto.RegisterDTO;
import liuwanghui.dto.ResetPasswordDTO;
import liuwanghui.dto.VerifyIdentityDTO;
import liuwanghui.service.AuthService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/auth")
@RequiredArgsConstructor
@CrossOrigin
@Tag(name = "认证", description = "登录注册相关接口")
public class AuthController {

    @Autowired
    private AuthService authService;

    @PostMapping("/login")
    @Operation(summary = "用户登录")
    public Result login(@RequestBody @Valid LoginDTO loginDTO) {
        return authService.login(loginDTO);
    }

    @PostMapping("/register")
    @Operation(summary = "用户注册")
    public Result register(@RequestBody @Valid RegisterDTO registerDTO) {
        return authService.register(registerDTO);
    }

    @PostMapping("/reset-password")
    @Operation(summary = "重置密码")
    public Result resetPassword(@RequestBody @Valid ResetPasswordDTO resetPasswordDTO) {
        return authService.resetPassword(resetPasswordDTO);
    }

    @PostMapping("/verify-identity")
    @Operation(summary = "身份验证")
    public Result verifyIdentity(@RequestBody @Valid VerifyIdentityDTO verifyIdentityDTO) {
        return authService.verifyIdentity(verifyIdentityDTO);
    }
} 